package com.local.goods.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GoodsWebConfig {

    @Value("${elasticsearch.server}")
    private String esServer;//192.168.40.3:9200

    /**
     * 声明elasticsearch客户端对象
     * @return
     */
    @Bean
    public RestHighLevelClient esClient() {
        return new RestHighLevelClient(RestClient.builder(
                HttpHost.create(this.esServer)
        ));
    }
}
